package com.bw.mvvm_comom.network.inteceptor;

import java.io.IOException;

import okhttp3.Interceptor;
import okhttp3.Request;
import okhttp3.Response;

public class ErrorInterceptor implements Interceptor {

    @Override
    public Response intercept(Chain chain) throws IOException {
        Request request = chain.request();
        Response proceed = chain.proceed(request);
        if (proceed.code() == 200)
            return proceed;
        Response builder = new Response.Builder()
                .code(200)
                .headers(proceed.headers())
                .message(proceed.message())
                .protocol(proceed.protocol())
                .body(proceed.body())
                .build();
        return builder;
    }
}
